package com.caifu.enums;

import com.caifu.bean.EnumBean;
import org.apache.commons.lang.StringUtils;

import java.util.ArrayList;
import java.util.List;

public enum SysOrganization_type {
    TYPE_1("1","管理中心"),
    TYPE_2("2","服务中心"),
    TYPE_3("3","村/社区"),
    TYPE_4("4","养老机构");

    private String key;
    private String value;
    private SysOrganization_type(String key, String value){
        this.key=key;
        this.value=value;
    }
    public static SysOrganization_type valueOfkey(String key){
        if(StringUtils.isBlank(key)){
            throw new IllegalArgumentException("value" + key
                    + " is blank");
        }
        for (SysOrganization_type education:values()){
            if(education.getKey().equals(key)){
                return education;
            }
        }
        System.out.println("状态不存在");
        return null;
    }

    public static List<EnumBean> iteratorEnum(){
        List<EnumBean> enumBeanList = new ArrayList<EnumBean>();
        for(SysOrganization_type place : SysOrganization_type.values()){
            EnumBean enumBean = new EnumBean();
            enumBean.setKey(place.getKey());
            enumBean.setValue(place.getValue());
            enumBeanList.add(enumBean);
        }
        return enumBeanList;
    }


    public String getKey() {
        return key;
    }
    public void setKey(String key) {
        this.key = key;
    }
    public String getValue() {
        return value;
    }
    public void setValue(String value) {
        this.value = value;
    }
}
